{% load i18n %}
{% load rich_text %}

{% if schedule.comment %}
    <p>{{ schedule.comment|rich_text }}</p>
{% elif schedule.changes.action == "create" %}
    <p>{{ phrases.schedule.first_schedule }}</p>
{% elif not schedule.changes.count %}
    <p>–</p>
{% endif %}
{% if schedule.changes.count %}
    {% if schedule.changes.new_talks|length > 0 %}
        {% if schedule.changes.new_talks|length > 1 %}
            <p>{% translate "We have new sessions!" %}</p>
            <ul>
                {% for talk in schedule.changes.new_talks %}
                    <li>
                        <a href="{{ talk.submission.urls.public }}">{{ talk.submission.display_title_with_speakers }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% else %}
            <p>
                {% translate "We have a new session: " %}
                {% for talk in schedule.changes.new_talks %}
                    <a href="{{ talk.submission.urls.public }}">{{ talk.submission.display_title_with_speakers }}</a>.
                {% endfor %}
        {% endif %}
        </p>
    {% endif %}

    {% if schedule.changes.canceled_talks|length > 0 %}
        {% if schedule.changes.canceled_talks|length > 1 %}
            <p>{% translate "Sadly, we had to cancel sessions:" %}</p>
            <ul>
                {% for talk in schedule.changes.canceled_talks %}
                    <li>{{ talk.submission.display_title_with_speakers }}</li>
                {% endfor %}
            </ul>
        {% else %}
            <p>
                {% translate "We sadly had to cancel a session: " %}
                {% for talk in schedule.changes.canceled_talks %}{{ talk.submission.display_title_with_speakers }}{% endfor %}
            </p>
        {% endif %}
    {% endif %}

    {% if schedule.changes.moved_talks|length > 0 %}
        {% if schedule.changes.moved_talks|length > 1 %}
            <p>
                {% translate "We had to move some sessions, so if you were planning on seeing them, check their new dates or locations:" %}
            </p>
            <ul>
                {% for talk in schedule.changes.moved_talks %}
                    <li>
                        <a href="{{ talk.submission.urls.public }}">{{ talk.submission.display_title_with_speakers }}</a>
                        {% if talk.old_room == talk.new_room %}
                            ({{ talk.old_start }} → {{ talk.new_start }})
                        {% elif talk.old_start == talk.new_start %}
                            ({{ talk.old_room }} → {{ talk.new_room }})
                        {% else %}
                            ({{ talk.old_start }}, {{ talk.old_room }} → {{ talk.new_start }}, {{ talk.new_room }})
                        {% endif %}
                    </li>
                {% endfor %}
            </ul>
        {% else %}
            <p>
                {% translate "We have moved a session around: " %}
                {% for talk in schedule.changes.moved_talks %}
                    <a href="{{ talk.submission.urls.public }}">{{ talk.submission.display_title_with_speakers }}</a>
                    {% if talk.old_room == talk.new_room %}
                        ({{ talk.old_start }} → {{ talk.new_start }})
                    {% elif talk.old_start == talk.new_start %}
                        ({{ talk.old_room }} → {{ talk.new_room }})
                    {% else %}
                        ({{ talk.old_start }}, {{ talk.old_room }} → {{ talk.new_start }}, {{ talk.new_room }}).
                    {% endif %}
                {% endfor %}
            </p>
        {% endif %}
    {% endif %}
{% endif %}
